
let mwindow;
if(typeof window === 'undefined') {
    mwindow = global;
} else {
    mwindow = window;
}

export default class Dep {
    constructor() {
        // 用来保存收集到的Watcher
        this.deps = [];
    }
    // 增加新的依赖
    add() {
        if(mwindow.$MyTarget) {
            this.deps.push(mwindow.$MyTarget);
        }
    }
    // 广播
    notify(newV,oldV) {
        for(let i=0;i<this.deps.length;i++) {
            this.deps[i].update(newV,oldV);
        }
    }
}